package com.beself.service.impl;

import com.beself.dao.TMineMapper;
import com.beself.dao.TProblemMapper;
import com.beself.entity.TMine;
import com.beself.entity.TProblem;
import com.beself.service.MineService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class MineServiceImpl implements MineService {

    @Resource
    private TMineMapper tMineMapper;

    @Resource
    private TProblemMapper tProblemMapper;
    @Override
    public TMine findMine(Integer uId) {
        TMine tMine = tMineMapper.selectByPrimaryKey(uId);
        return tMine;
    }

    @Override
    public boolean updateMine(TMine tMine) {
        int i = tMineMapper.updateByPrimaryKeySelective(tMine);
        if (i > 0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean insertProblem(TProblem tProblem) {

        int i = tProblemMapper.insertSelective(tProblem);

        if (i > 0){
            return  true;
        }
        return false;
    }

    @Override
    public TMine showSuperUser(TMine tMine) {
        Integer uid = tMine.getuId();
        TMine mine = tMineMapper.selectByPrimaryKey(uid);

        Integer ismember = mine.getmIsmember();
        if (ismember == 1){
            //不是会员

        } else {
            //是会员

        }

        return null;
    }
}
